class Solution
{
public:
    int findComplement(int num)
    {
        // 0 < n < 2^31, 需要判断左移溢出
        int mask = (1LL << (32 - __builtin_clz(num))) - 1;
        return num ^ mask;
    }
};